package com.lichuandi.springbootdemo1.util;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lichuandi.springbootdemo1.entity.User;

import java.lang.reflect.Type;
import java.util.List;

public class JsonTest {
    public static void main(String[] args) {
        String json = "[{\"user_name\":\"user_name\",\"user_password\":\"user_password\"}]";
        Gson gson = new Gson();
        Type userListType = new TypeToken<List<User>>(){}.getType();
        List<User> users = gson.fromJson(json, userListType);
        System.out.println(users);
    }
}
